<!-- wyf 2022-1-20 -->
<template>
  <a-input-search
    v-model:value="iptValue"
    class="input-search-item"
    :class="{'input-search-item-clear': allowClear}"
    :disabled="disabled"
    :placeholder="placeholder"
    :allow-clear="allowClear"
    :loading="loading"
    :enter-button="enterButton"
  >
    <template v-if="$slots.enterButton" #enterButton>
      <slot name="enterButton" />
    </template>
  </a-input-search>
</template>

<script>
import { defineComponent, computed } from 'vue'
import { InputSearch } from 'ant-design-vue'
export default defineComponent({
  name: 'ZInputSearch',
  components: {
    AInputSearch: InputSearch
  },
  props: {
    value: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: undefined
    },
    disabled: {
      type: Boolean,
      default: false
    },
    allowClear: {
      type: Boolean,
      default: false
    },
    loading: {
      type: Boolean,
      default: false
    },
    enterButton: {
      type: Boolean,
      default: undefined
    }
  },
  setup(props, _ref) {
    const iptValue = computed({
      get() {
        return props.value
      },
      set(val) {
        _ref.emit('update:value', val)
      }
    })
    return {
      iptValue
    }
  }
})
</script>
